<?php
/**   
* @Title:BaseBean.php
* @Description: 继承了AbatractBean.php实现了保存前的基本验证
* @author tangchuan
* @CreateDate 2016-03-01   
* @version V1.0   
*/ 

class BaseBean extends AbstractBean{
    
    protected $defDbCfg = array(
            "host"=>"s1.wfserver.com.cn,40033",
            "user"=>"runxun",
            "password"=>"runxundev",
            "database"=>"RunXun"
        );

    

    protected function _iconv($value,$type="") {
     	if(value!=null && strstr($type,"char")){
     		$value = iconv("UTF-8", "GB2312", $value);
     	}

        return $value;
    }

    public function save(){
        $field = $this->emptyCheck();
        if($field!=null && $field!=""){
            $fieldName = $this->_mustFields[$field];
            CustomerException::ThrowException("字段[".$fieldName."]不可为空");
        }

        $field = $this->uniqueCheck();
        if($field!=null && $field!=""){
            $fieldName = $this->_uniqueFields[$field];
            CustomerException::ThrowException($fieldName."[".$this->getStringValue($field)."]已经存在");
        }
        parent::save();
    }

}
?>